package wu.com;

import java.sql.*;

public class Yonghudenglu {
        public static boolean login(String id1,String mima) {
            Connection connection = null;
            Statement statement = null;
            ResultSet res=null;
            try {
                Class.forName("com.mysql.jdbc.Driver");
                connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/studentmessage", "root", "0804");
                statement = connection.createStatement();
                String sql = "SELECT * from message where id='"+id1+"' and password='"+mima+"'";
                statement=connection.prepareStatement(sql);
                res = statement.executeQuery(sql);
                if (res.next()) {
                    return true;
                } else {
                    return false;
                }

            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                try {
                    res.close();
                    statement.close();
                    connection.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            return false;
        }
    }